<template>
  <div class="parentWrapper">
    <Parent :parentData="parentData.parent" v-if="parentData.parent" />
    <div class="info">
      <div class="name">
        {{ parentData.user.nickname || parentData.user.usrename }}
      </div>
      <div class="date">2小时前</div>
      <div class="huifu" @click="sendComment">回复</div>
    </div>
    <div class="content">{{ parentData.content }}</div>
  </div>
</template>

<script>
// 引入了一个 eventBus vue 实例
import eventBus from "../../utils/eventBus";
export default {
  name: "Parent",
  props: ["parentData"],
  components: { eventBus },
  methods: {
    sendComment() {
      // 可以用 $emit 给这个实例触发事件
      eventBus.$emit("sendComment", this.parentData.id);
    },
  },
};
</script>

<style lang="less" scoped>
.parentWrapper {
  border: 1px solid #ddd;
  padding: 2/360 * 100vw;
  background-color: #ffffee;
  box-shadow: 0px 0px 1px #000;
  .info {
    display: flex;
    align-items: center;
    color: #888;
    font-size: 10 / 360 * 100vw;
    padding: 10 / 360 * 100vw 0;
    .name {
      color: #333;
      font-size: 12 / 360 * 100vw;
      padding-right: 10 / 360 * 100vw;
    }
    .date {
      flex-grow: 1;
    }
    .huifu {
      margin-right: 10 / 360 * 100vw;
    }
  }
  .content {
    font-size: 12 / 360 * 100vw;
    padding: 4 / 360 * 100vw;

    word-break: break-all;
  }
}
</style>